package com.cskaoyan.shopping.service.impl;

import com.cskaoyan.shopping.constants.GlobalConstants;
import com.cskaoyan.shopping.converter.ContentConverter;
import com.cskaoyan.shopping.dal.entitys.PanelContent;
import com.cskaoyan.shopping.dal.entitys.PanelContentItem;
import com.cskaoyan.shopping.dal.persistence.PanelContentMapper;
import com.cskaoyan.shopping.dto.NavListResponse;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelContentItemDto;
import com.cskaoyan.shopping.dto.RecommendResponse;
import com.cskaoyan.shopping.service.IContentService;
import com.cskaoyan.user.constants.UserRetCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.LinkedList;
import java.util.List;

/**
 * @author D_y_Y
 * @since 2022/06/18 16:36
 */
@Service
@Slf4j
public class IContentServiceImpl implements IContentService {

    @Autowired
    PanelContentMapper panelContentMapper;

    @Autowired
    ContentConverter contentConverter;
    @Override
    public NavListResponse queryNavList() {
      log.error("IContentServiceImpl.queryNavList");
        NavListResponse response = new NavListResponse();
        Example example = new Example(PanelContent.class);
        example.createCriteria().andEqualTo("panelId", GlobalConstants.HEADER_PANEL_ID);
        List<PanelContent> panelContents = panelContentMapper.selectByExample(example);
        List<PanelContentDto> panelContentDtos = contentConverter.panelContents2Dto(panelContents);
        response.setPannelContentDtos(panelContentDtos);
        response.setCode(UserRetCode.SUCCESS.getCode());
        response.setMsg(UserRetCode.SUCCESS.getMessage());

        return  response;


    }
}
